﻿CREATE FUNCTION copymenutheonhom
(	
@IDPhanNhomNguoiDung int,  
@ViTri int,  
@ChuongTrinh int,  
@NhomMenu int  
)
RETURNS TABLE 
AS
RETURN 
(
select a.ID,a.Quyen_CapNhat,a.Quyen_Xem,a.Quyen_Xoa ,a.IDPhanNhomNguoiDung,a.IDCapQuyen,a.IDPhanNhomMenu
from QuanTri_EditUserRoleInGroup a,QuanTri_CapQuyenNguoiDungSuDungMenu b,QuanTri_PhanNhomMenu c,DanhMuc_Menu d  
Where a.IDCapQuyen=b.ID and a.IDPhanNhomMenu=c.ID and c.MenuID=d.MenuID  
and a.IDPhanNhomNguoiDung=@IDPhanNhomNguoiDung and b.MaChuongTrinh=@ChuongTrinh and b.IDViTri=@ViTri and c.MaNhomMenuND=@NhomMenu

)